﻿<UserControl x:Class="Microsoft.Research.ScientificWorkflow.ManagementStudioControls.WorkflowManagerModule.CompletedJobsListView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" AutomationProperties.AutomationId="CompletedWorkflowsControl"
    xmlns:local="clr-namespace:Microsoft.Research.ScientificWorkflow.ManagementStudioControls.WorkflowManagerModule"
        xmlns:converters="clr-namespace:Microsoft.Research.ScientificWorkflow.ManagementStudioControls.WorkflowManagerModule"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:Controls="clr-namespace:Microsoft.Research.ScientificWorkflow.UIDesigner;assembly=Microsoft.Research.ScientificWorkflow.UIDesigner">
    <UserControl.Resources>
        <ContextMenu x:Key="EmptyContextMenu"/>
        <BooleanToVisibilityConverter x:Key="VisibilityConverter"></BooleanToVisibilityConverter>
        <converters:DateTimeConverter x:Key="DateTimeConverter"></converters:DateTimeConverter>
        <DataTemplate x:Key="DetailsTemplate">
            <TextBlock MaxHeight="15" Text="{Binding Path=Description}" ToolTip="{Binding Path=Description}" TextTrimming="CharacterEllipsis"></TextBlock>
        </DataTemplate>
    </UserControl.Resources>
    
    <Grid>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="25"/>
                <RowDefinition Height="36"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <Border CornerRadius="5,5,0,0" Grid.Row="1">
                <Border.Background>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="#FFFBFBFB" Offset="0"/>
                        <GradientStop Color="#FFF0F0F0" Offset="1"/>
                    </LinearGradientBrush>
                </Border.Background>
                <Grid>
                    <StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
                        <Button Style="{DynamicResource provenanceButton}" ToolTip="Provenance" Command="{Binding Path=ShowProvenanceCommand}" CommandParameter="{Binding ElementName=DisplayListView, Path=SelectedItem}" Width="26" Height="26" Margin="5,0,0,0" AutomationProperties.AutomationId="ProvenanceButton"/>
                        <Button Style="{DynamicResource deleteButton}" ToolTip="Delete" Command="{Binding Path=DeleteJobCommand}" CommandParameter="{Binding ElementName=DisplayListView, Path=SelectedItem}" Width="26" Height="26" Content="Button" Margin="5,0,0,0" AutomationProperties.AutomationId="DeleteJobButton"/>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                        <Button Style="{DynamicResource refreshButton}" Margin="0,0,10,0" Width="24" Height="24" Command="{Binding Path=RefreshListCommand}" ToolTip="Refresh" AutomationProperties.AutomationId="RefreshCompletedJobs"></Button>
                    </StackPanel>
                </Grid>
            </Border>
            <Grid Grid.Row="2" Margin="5,10,5,5" Grid.RowSpan="2">
                <Controls:SortListView KeyDown="DisplayListView_KeyDown" SelectionMode="Single" SelectedIndex="{Binding Path=SelectedIndex}" Style="{DynamicResource ListViewStyle1}" ItemsSource="{Binding Path=Items}" ScrollViewer.CanContentScroll="True" x:Name="DisplayListView" IsSynchronizedWithCurrentItem="True" ItemTemplate="{DynamicResource ParentDataTemplate}" Width="Auto" Height="Auto" >
                    <Controls:SortListView.ItemContainerStyle>
                        <Style TargetType="{x:Type ListViewItem}">
                            <Setter Property="ContextMenu" Value="{StaticResource EmptyContextMenu}"/>
                            <Setter Property="Template" Value="{DynamicResource ListViewItemControlTemplate1}"/>
                            <EventSetter Event="ContextMenuOpening" Handler="ContextMenu_ContextMenuOpening"></EventSetter>
                            <EventSetter Event="MouseDoubleClick" Handler="ListViewItemDoubleClicked"></EventSetter>
                        </Style>
                    </Controls:SortListView.ItemContainerStyle>

                    <Controls:SortListView.View>
                        <GridView>
                            <Controls:SortListViewColumn MinimumWidth="130" SortProperty="JobName" Width="150" Header="Job Name" DisplayMemberBinding="{Binding Path=JobName}" />
                            <Controls:SortListViewColumn MinimumWidth="130" SortProperty="WorkflowName" Width="130" Header="Workflow Name" DisplayMemberBinding="{Binding Path=WorkflowName}" />
                            <Controls:SortListViewColumn MinimumWidth="100" SortProperty="ScheduledBy" Width="120" Header="Executed By" DisplayMemberBinding="{Binding Path=ScheduledBy}" />
                            <Controls:SortListViewColumn MinimumWidth="100" SortProperty="NodeName" Width="120" Header="Node" DisplayMemberBinding="{Binding Path=NodeName}" />
                            <Controls:SortListViewColumn MinimumWidth="130" SortProperty="StartTime" Width="130" Header="Date Started" DisplayMemberBinding="{Binding Path=StartTime, Converter={StaticResource DateTimeConverter}}" />
                            <Controls:SortListViewColumn MinimumWidth="130" SortProperty="CompletedTime" SortByDefault="True" DefaultSortDirection="Descending" Width="130" Header="Date Completed" DisplayMemberBinding="{Binding Path=CompletedTime, Converter={StaticResource DateTimeConverter}}" />
                            <Controls:SortListViewColumn MinimumWidth="110" SortProperty="Status" Width="120" Header="Status" DisplayMemberBinding="{Binding Path=Status}" />
                            <Controls:SortListViewColumn MinimumWidth="200" Width="200" Header="Details" CellTemplate="{StaticResource DetailsTemplate}"/>
                        </GridView>
                    </Controls:SortListView.View>
                </Controls:SortListView>
                <Grid Background="White" Visibility="{Binding Converter={StaticResource VisibilityConverter}, Path=EmptyList}" Width="{Binding Path=Width, ElementName=ListviewHost}" Height="{Binding Path=Height, ElementName=ListviewHost}">
                    <TextBlock HorizontalAlignment="Center" Foreground="Gray">No Items to be shown</TextBlock>
                </Grid>
            </Grid>
            <Border Margin="0,0,0,0" CornerRadius="5,5,0,0" BorderThickness="0,0,0,1" BorderBrush="#FFFFFFFF">
                <Border.Background>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="#FFFFFFFF" Offset="0"/>
                        <GradientStop Color="#FFE8E8E8" Offset="1"/>
                    </LinearGradientBrush>
                </Border.Background>
                <TextBlock Text="{Binding Path=ListViewTitle}" TextWrapping="Wrap" FontSize="14" FontWeight="Normal" Margin="7,2,0,0"/>
		</Border>
        </Grid>
    </Grid>
</UserControl>
